/**
 * @param {number[]} nums
 * @param {number} target
 * @return {number[]}
 */
var twoSum = function (nums, target) {
    const map = new Map()
    let len = nums.length
    for(let i = 0;i<len;i++){
        const item = map.get(target-nums[i])
        if(item!==undefined){
            return [item,i]
        }
        map.set(nums[i],i)
    }
    return []
};

console.log(twoSum([2,7,11,15],9))